#!/bin/sh

sh_filename=`readlink -f $0`
sh_dir=`dirname $sh_filename`

wget -e "http_proxy=http://10.45.66.240:9901" -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' \
| awk -F\| '/CN\|ipv4/ { printf("%s/%d\n", $4, 32-log($5)/log(2)) }' \
> /etc/chinadns_chnroute.txt.new

if [ `cat /etc/chinadns_chnroute.txt.new |wc -l |cut -d " " -f 1` -ne 0 ] ; then
    cp /etc/chinadns_chnroute.txt.new /etc/chinadns_chnroute.txt
    echo "-- download from net ok."
    echo "-- add my dns."
    cat $sh_dir/my_dns.txt >> /etc/chinadns_chnroute.txt
else
    echo "-- download from net failed."

fi
